// 判断是否展示该表单项
import { TYPE_MODEL } from "@/types/component";

export function isShowFormItem(item, type, formData) {
    try {
        if (item.key === 'action') throw '这是操作栏';
        if (type === TYPE_MODEL.EDIT) {
            if (item.displayEdit === false) {
                return false;
            } else if (typeof item.displayEdit === 'function') {
                return item.displayEdit(formData);
            }
            return true;
        } else if (type === TYPE_MODEL.ADD) {
            if (item.displayAdd === false) {
                return false;
            } else if (typeof item.displayAdd === 'function') {
                return item.displayAdd(formData);
            }
            return true;
        }
    } catch (e) {
        return false;
    }
}
